{extend name="public/base" /} {block name="body"}
<div class="ibox float-e-margins">
	<div class="content-tabs">
	<ol class="breadcrumb">
		<li>
			<a href="{:url('index/index')}"><i class="fa fa-home"></i></a>
		</li>
		<li><strong>订单列表</strong></li>
	</ol>
</div>
<div class="ibox float-e-margins">
	{include file="order/top"}
	<div class="ibox-content">
		<form id="myForm" class="form-horizontal" method="post" action="{:url('index',['status'=>$status])}">
		    <div class="row">
				<div class="form-group" style="padding-left: 30px;">
					订单号 <input type="text" id="order_number" name="order_number" value="" placeholder="请输入订单号" class="bank"/>
					商家名称 <input type="text" id="store_name" name="store_name" value="" placeholder="请输入商户名称" class="bank"/>
		        	下单时间 <input id='start_time' name='start_time'  style="width: 100px;" onclick='WdatePicker()' type='text' placeholder="开始时间" class="bank"/>
					<input id='end_time' name='end_time'  style="width: 100px;" onclick='WdatePicker()' type='text' placeholder="结束时间" class="bank"/>
					收货人姓名 <input type="text" id="receiver" name="receiver" value="" placeholder="请输入收货人姓名" class="bank"/>
					手机号 <input type="text" id="receiver_mobile" name="receiver_mobile" value="" placeholder="请输入收货人手机" class="bank"/>
					<button type="submit" class="btn btn-sm btn-primary"><li class="fa fa-search"> 查询</li></button>
				</div> 
        	</div>
        </form>
		<div class="hr-line-dashed" style="margin: 3px;"></div>
		<a href="{:url('export',['status'=>$status])}" class="btn btn-xs btn-primary">导出订单信息</a>
            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <tbody id="list">
                        	{foreach name="list1" item='order'}
                        	<tr><td colspan="10">订单号:{$order.sn}
                        	 <tr class="long-tr">
	                        	<th>商品</th>
	                            <th>单价/数量</th>
	                            <th>用户支付</th>
								<th>买家</th>
	                            <th>下单时间</th>
	                            <th>订单状态</th>
	                            <th>实付金额</th>
	                        </tr>
                        	{foreach name="order['items']" item="ad" key="k" }
                        	<tr>
                        		<td><img src="{$ad.thumb}"  width="50px"/>{$ad.goods_name}</td>
                        		<td>{$ad.price}<br>{$ad.number}{$ad.unit}</td>         
                        		<td>{$ad.total_price}</td>
                        		<td>{$order.nick_name}</td>
                        		<td>{$ad.add_time}</td>
                        		{if condition="$k==0"}
                        			<td rowspan="<?php echo count($order['items']) ?>">{if $order.order_state==1}
                        			待付款
                        			{elseif $order.order_state==2}
                        			拼团中
                        			{elseif $order.order_state==3}
                        			待发货
                        			<br />
                        			<a class="btn btn-primary bnt-sm" onclick="show_fh('{$order.id}')">发货</a>
                        			{elseif $order.order_state==4}
                        			已发货
                        			{elseif $order.order_state==5}
                        			已完成
                        			{elseif $order.order_state==6}
                        			已关闭
                        			{/if}
                        			</td>
                        			<td rowspan="<?php echo count($order['items']) ?>">
                        			{$order.pay_price}
                        			</td>
                        		{/if}
                        	</tr>
                        	{/foreach}
                        	{/foreach}
                        </tbody>
                    </table>
                    <div style="text-align: right;">
                      {$list->render()}
                    </div>
                </div>
            </div>
        </div>
            
</div>
<!--发货start-->
<div class="modal-content" id="map-dialog" style="display:none;height: 350px; position:fixed;z-index:1000;background:#fff;left: 35%;top: 20%;width:550px;">
	<div class="modal-header" style="padding: 5px;">
		<h2>订单发货<button type="button" class="close" data-dismiss="modal" aria-hidden="true" onclick="$('#map-dialog').hide()">×</button></h2></div>
	<div class="modal-body">
		<div id="map-container" class="row" style="margin-left:10px;overflow: hidden; position: relative; z-index: 0;  color: rgb(0, 0, 0); text-align: left;">
			<div class="form-group">
				<label class=" control-label">订单号</label>
				<div class="input-group col-sm-5" style="display: inline;padding-left: 30px;">
					<span id="sn"></span>
				</div>
			</div>
			<div class="form-group">
				<label class=" control-label">收货人</label>
				<div class="input-group " style="display: inline;padding-left: 30px;">
					<span id="shr"></span>
				</div>
			</div>
			<div class="form-group">
				<label class=" control-label">收货地址</label>
				<div class="input-group col-sm-5" style="display: inline;padding-left: 30px;">
					<span id="address"></span>
				</div>
			</div>
			<div class="form-group">
				<label class=" control-label">物流公司</label>
				<div class="input-group col-sm-5" style="display: inline;padding-left: 30px;">
					<select id="express">
						<option value="">
							选择物流公司
						</option>
						{foreach name="express" item='exp'}
						<option value="{$exp['value']['no']}">
							{$exp['value']['name']}
						</option>
						{/foreach}
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class=" control-label" style="float: left;">物流单号</label>
				<div class="input-group " style="display: inline;padding-left: 30px;">
					<input type="text" style="width: 250px;float: left;margin-left: 30px;" id="express_no" name="express_no" value="" placeholder="请输入物流单号" class="form-control" />
				</div>
			</div>
		</div>
		<br />
		<div class="modal-footer ">
			<a class="btn btn-default" data-dismiss="modal" onclick="javascript:$('#map-dialog').hide()">取消</a>
			<button type="button" onclick="fahuo(this)" class="btn btn-primary ">确认</button>
		</div>
	</div>
</div>
<!--发货end-->

{/block} {block name="script"}
<script src="__JS__/jquery.form.js"></script>
<script src="__LIB__/validate/jquery.validate.min.js"></script>
<script src="__LIB__/validate/messages_zh.min.js"></script>
<script src="__LIB__/validate/add_validate.min.js"></script>
<script src="__LIB__/fileinput/js/fileinput.min.js"></script>
<script src="__LIB__/fileinput/js/locales/zh.js"></script>
<script src="__LIB__/datepicker/WdatePicker.js"></script>
<script>
//顶部导航 
if({$status}==0){	
	$("#li-bar-si").addClass("active");
}
if({$status}==1){
	$("#li-bar-site").addClass("active");
  }
if({$status}==2){
	$("#li-bar-sms").addClass("active");
  }
if({$status}==3){
	$("#li-bar-pay").addClass("active");
  }
if({$status}==4){
	$("#li-bar-log").addClass("active");
  }
if({$status}==5){
	$("#li-bar-wechat").addClass("active");
  }
if({$status}==6){
	$("#li-bar-three").addClass("active");
}
//发货
	function show_fh(id) {
		$.ajax({
			url: '/admin/order/orderInfo',
			data: {
				order_id: id
			},
			//成功了的回调，并且带有返回值
			success: function(data) {
				if(data.code == 200) {
					var dt = data.order;
					$("#sn").text(dt.sn);
					$("#shr").text(dt.receiver + " " + dt.receiver_mobile);
					$("#address").text(dt.address);

				} else {
					layer.msg("订单不存在");
				}
			}
		})
		$("#map-dialog").show();
	}
	
	function fahuo() {
		$(this).attr("disabled","disabled");
		var sn = $("#sn").text();
		var express = $("#express").val();
		var express_no = $("#express_no").val();
		if(express == "") {
			layer.msg("请选择物流方式");
			return false;
		}
		if(express_no == "") {
			layer.msg("请输入物流单号");
			return false;
		}
		$.ajax({
			//请求的url
			//注意，如果我们使用路由器的情况下，我们需要设置一下本地服务器的ip地址
			url: '/admin/order/fahuo',
			//请求的过程中传递过去的参数 json
			data: {
				sn: sn,
				express: express,
				express_no: express_no
			},
			//成功了的回调，并且带有返回值
			success: function(data) {
				layer.msg(data.msg, {
					icon: 1,
					time: 1000 //2秒关闭（如果不配置，默认是3秒）
				}, function() {
					if(data.code == 200) {
						$('#map-dialog').hide();
						location.reload();
					}
				});

			}
		})

	}
</script>
<style>
.bank{
	width: 150px;
    height:30px;
    text-align:center;
    border-radius:5px;
}
</style>
{/block}